package com.examination.dao;
import com.examination.bean.User;
import com.examination.utils.DbUtil;
import java.sql.*;
/**
 * @Auther: GongXl
 * @Date: 026 14:45
 * @Description:
 */
public class RegisterDao {

    public String regUser(User user) {
        int row = 0;
        //数据库查询得到的
        Connection conn = DbUtil.getConnInstance();
        //3.操作数据库，实现增删改查
        ResultSet rs = null;
        PreparedStatement stmt = null;

        try {
            String e_user = "INSERT INTO e_user (name,password,role_type) VALUES (?,?,?)";
            stmt = conn.prepareStatement(e_user);
            stmt.setString(1,user.getName());
            stmt.setString(2,user.getPassword());
            stmt.setString(3,user.getRoleType());
            row = stmt.executeUpdate();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row +"" ;
    }
}